import { Controller, Get, Post, Body } from '@nestjs/common';
import { LongPollingService } from './long-polling.service';

@Controller('long-polling')
export class LongPollingController {
  constructor(private readonly longPollingService: LongPollingService) {}

  @Get()
  async getCount() {
    return this.longPollingService.waitForUpdate();
  }

  @Post('increment')
  increment() {
    return this.longPollingService.increment();
  }

  @Post('reset')
  reset() {
    return this.longPollingService.reset();
  }

  @Post('set-interval')
  setInterval(@Body() body: { interval: number }) {
    return this.longPollingService.setInterval(body.interval);
  }
}
